package com.market.coupon.server.service.impl;

import java.util.List;

import com.market.common.security.service.TokenService;
import com.market.coupon.common.domain.DTO.DTOCoupon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.market.coupon.server.mapper.TUserRepertoryMapper;
import com.market.coupon.common.domain.TUserRepertory;
import com.market.coupon.server.service.ITUserRepertoryService;

/**
 * 用户优惠券Service业务层处理
 *
 * @author market
 * @date 2024-03-05
 */
@Service
public class TUserRepertoryServiceImpl implements ITUserRepertoryService
{
    @Autowired
    private TUserRepertoryMapper tUserRepertoryMapper;

    /**
     * 查询用户优惠券
     *
     * @param userRepertoryId 用户优惠券主键
     * @return 用户优惠券
     */
    @Override
    public TUserRepertory selectTUserRepertoryByUserRepertoryId(Long userRepertoryId)
    {
        return tUserRepertoryMapper.selectTUserRepertoryByUserRepertoryId(userRepertoryId);
    }

    /**
     * 查询用户优惠券列表
     *
     * @param tUserRepertory 用户优惠券
     * @return 用户优惠券
     */
    @Override
    public List<TUserRepertory> selectTUserRepertoryList(TUserRepertory tUserRepertory)
    {
        return tUserRepertoryMapper.selectTUserRepertoryList(tUserRepertory);
    }

    /**
     * 新增用户优惠券
     *
     * @param tUserRepertory 用户优惠券
     * @return 结果
     */
    @Override
    public int insertTUserRepertory(TUserRepertory tUserRepertory)
    {
        return tUserRepertoryMapper.insertTUserRepertory(tUserRepertory);
    }

    /**
     * 修改用户优惠券
     *
     * @param tUserRepertory 用户优惠券
     * @return 结果
     */
    @Override
    public int updateTUserRepertory(TUserRepertory tUserRepertory)
    {
        return tUserRepertoryMapper.updateTUserRepertory(tUserRepertory);
    }

    /**
     * 批量删除用户优惠券
     *
     * @param userRepertoryIds 需要删除的用户优惠券主键
     * @return 结果
     */
    @Override
    public int deleteTUserRepertoryByUserRepertoryIds(Long[] userRepertoryIds)
    {
        return tUserRepertoryMapper.deleteTUserRepertoryByUserRepertoryIds(userRepertoryIds);
    }

    /**
     * 删除用户优惠券信息
     *
     * @param userRepertoryId 用户优惠券主键
     * @return 结果
     */
    @Override
    public int deleteTUserRepertoryByUserRepertoryId(Long userRepertoryId)
    {
        return tUserRepertoryMapper.deleteTUserRepertoryByUserRepertoryId(userRepertoryId);
    }
    @Autowired
    private TokenService tokenService;

    @Override
    public List<DTOCoupon> queryType() {
        Long userid = tokenService.getLoginUser().getUserid();
        List<DTOCoupon> list=tUserRepertoryMapper.queryType(userid);
        return list;
    }
}
